<?php
if($this->input->cookie('search')){
	$searchData = $this->input->cookie('search');
	$str = explode("|",$searchData);
	if(count($str) >2){
		$default =array();
		$default['fieldSearch'] = @$str[0];
		$default['textSearch'] = @$str[1];
		$default['selCondition'] = @$str[2];
		$default['selCategory'] = @$str[3];
	}
}
?>
<form  id="frmAdvancedNormal" name="frmAdvancedNormal" method="post" action="<?php echo @$this->url_search;?>" class="form-inline">
	<div class="widget-box">
		<div class="widget-title">
			<span class="icon"><i class="glyphicon glyphicon-search"></i></span>
			<h5>Tìm kiếm</h5>
		</div>
		<div class="widget-content  padding">
			<input  type="text" name="txtSearch" id="txtSearchAdvanced" value="<?php echo @$default['textSearch'];?>" style="width:300px;" placeholder="Chuỗi cần tìm..."class="input-small form-control input-small"  >
			
			<select name="selFieldSearch">
				<?php
				foreach ($fields_search as $keys => $vals) {
				$check = "";
				if(@$default['fieldSearch'] == $keys)
				{
					$check = " selected";
				}
				?>
				<option value="<?php echo $keys;?>" <?php echo $check;?>><?php echo $vals;?></option>
							  
				<?php
				}?>         
				</select> 
			<select name="selCondition">
				<option value="=" <?php echo (@$default['selCondition'] != 'like')?' selected':''?>>Chính xác</option>
				<option value="like" <?php echo (@$default['selCondition'] == 'like')?' selected':''?>>Gần đúng</option>
			</select>
			<select name="selCategory[]" class="selCategory" multiple placeholder="Danh mục bài viết" style="">
			<?php 
				$default_value = explode(',', @$default['selCategory']);
	            foreach ($cat_tree as $key => $val) {
	                //print_r($value);
	                if (isset($default_value) && ((is_array($default_value)  && in_array($key,$default_value)) || (!is_array($default_value) && $key == $default_value)))
	                    echo '<option value="' . $key . '" selected="selected">' . $val . '</option>';
	                else
	                    echo '<option value="' . $key . '">' . $val . '</option>';
	            }
	            ?>
			</select>
			<br />
			<input class="btn btn-primary btn-mini" type="submit" name="btnSearchAdvanced" id="btnSearchAdvanced" value="Tìm kiếm" />
			<a href="<?php echo $this->url_index;?>/clean_search" class="btn btn-default  btn-mini">Hiển thị tất cả</a>
		</div>
	</div>
</form>